package titt.service.content;

import titt.head.HTTPHead;
import titt.io.IOFactory;
import titt.io.socket.out.LengthBufferedOutputStream;

public class NuderUtil {
	
	private static int inc = 0;
	
	public static String generateID(String seed) {
		return "__titt__" + seed + "__" + inc++;
	}

	public static int getHeadLength(HTTPHead h) {
		try {
			LengthBufferedOutputStream tmp = new LengthBufferedOutputStream();

			IOFactory.createHeadWriter(tmp).writeHead(h);

			return tmp.getLength();
		}
		catch(Exception e) {
			return -1;
		}
	}}
